package cc.plumgo.ss.yo.entity;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

import cc.plumgo.j2me.utils.CustomEntity;
import cc.plumgo.ss.core.Constants;

public class Item extends CustomEntity {
	public static final int ITEM_BASEB = 0;
	public static final int ITEM_FOOTB = 1;
	public static final int ITEM_BASKETB = 2;
	public static final int ITEM_GLASS = 3;
	public static final int ITEM_CREAM = 4;

	private int showDelay = 10;
	private int type;
	private boolean picked;
	public Item(int type) {
		try {
			totalState = 1;
			sprites = new Sprite[totalState];
			Image image = Image.createImage(Constants.ITEM_SPRITE_IMGS[type]);
			sprites[0] = new Sprite(image, Constants.ITEM_SPRITE_W[type],
					Constants.ITEM_SPRITE_H[type]);
			sprites[0].setVisible(false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		picked = false;
		this.type = type;
	}
	
	public void setVisible(boolean visible) {
		sprites[0].setVisible(visible);
	}
	
	public Sprite getSprite() {
		return sprites[0];
	}

	public int getShowDelay() {
		return showDelay--;
	}

	public boolean isPicked() {
		return picked;
	}

	public void setPicked(boolean picked) {
		this.picked = picked;
	}

	public int getType() {
		return type;
	}
}